<template>
  <div id="question-term" style="height: 100%">123</div>
</template>


<script>
import * as echarts from 'echarts'
export default {
  name: 'discoverQuestion',
  data() {
    return {}
  },
  props: {
    dataScoure: {
      type: Array,
      default: () => [],
    },
  },
  mounted() {
    this.$nextTick(() => {
      let Ydata = []
      let Xdata = []
      this.dataScoure.map((item) => {
        Ydata.push(item.num)
        Xdata.push(item.name)
      })
      this.initCharts(Ydata, Xdata)
    })
  },
  methods: {
    initCharts(Ydata, Xdata) {
      var chartDom = document.getElementById('question-term')
      var myChart = echarts.init(chartDom)
      var option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        legend: {
          data: ['合计'],
          right:'0%',
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true,
        },
        xAxis: [
          {
            type: 'category',
            data: Xdata,
            axisTick: {
              alignWithLabel: true,
            },
          },
        ],
        yAxis: [
          {
            type: 'value',
          },
        ],
        series: [
          {
            name: '合计',
            type: 'bar',
            barWidth: '60%',
            data: Ydata,
          },
        ],
      }
      option && myChart.setOption(option)
    },
  },
}
</script>